package com.itheima.socketdemo1;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressDemo1 {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getByName("X1");
        String hostName = address.getHostName();
        System.out.println("主机名为：" + hostName);
        String ip = address.getHostAddress();
        System.out.println("IP为：" + ip);
    }
}
